<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .divA{
            height: 500px;
            width:500px;
            background-color: #000;
            display: flex;
        }
        .divB{
            height: 200px;
            width: 200px;
            background-color: #d65353;
            margin:auto;

        }

    </style>
</head>
<body>
    <div class="divA">
        <div class="divB"></div>
    </div>

    <script>
        var a = [1,2,[2,3],[3,4,5,[5,6]]]
        function dispatch(arr){
            var result = []
            for(var i in arr){
                if(arr[i] instanceof Array)
               { var temp = dispatch(arr[i])
                result = result.concat(temp)
            }
               else{
                   result.push(arr[i])
               }
            }
            return result
        }
        console.log(dispatch(a))
        var request = [1,2,3,4,5,6]
        function taskQueue(arr,index){
            if (index>=arr.length){return false}
            var succ1 = false
            var succ2 = false
            arr[index]().then(res=>(){
                succ1 =  true
                if(succ1&&succ2){
                    taskQueue(arr,index+2)
                }
            })
            arr[index+1]().then(res=>(){
                succ2 =  true
                if(succ1&&succ2){
                    taskQueue(arr,index+2)
                }
            })
        }
    </script>
</body>
</html>